import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Timestamps {
    public static void main(String[] args) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
            Date d1 = sdf.parse("2018-09-19 16:43:00");

            Date d2 = sdf.parse("2018-12-22 00:55:00");

            Calendar calendar = Calendar.getInstance();
            for (int i = 0; i < 10; i++) {
                calendar.setTime(d1);
                String time1 = sdf2.format(calendar.getTime());
                calendar.add(Calendar.MINUTE, 3);
                String time2 = sdf2.format(calendar.getTime());
                d1 = calendar.getTime();

                calendar.setTime(d2);
                calendar.add(Calendar.DAY_OF_MONTH, 1);
                d2 = calendar.getTime();
                String time3 = sdf2.format(calendar.getTime());
                System.out.println("db.bd_cultivatetimeslatitude.update({$and:[{\"receiveTime\" : {$gte:ISODate(\"" + time1 + "\")}},{\"receiveTime\" : {$lte:ISODate(\"" + time2 + "\")}}]},{$set:{\"receiveTime\":ISODate(\"" + time3 + "\")}},false,true);");
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
